package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	ProcessEventNew          = "mes.ProcessNew"
	ProcessEventBeforeCreate = "mes.ProcessBeforeCreate"
	ProcessEventBeforeUpdate = "mes.ProcessBeforeUpdate"
	ProcessEventBeforeSave   = "mes.ProcessBeforeCreate mes.ProcessBeforeUpdate"
	ProcessEventAfterCreate  = "mes.ProcessAfterCreate"
	ProcessEventAfterUpdate  = "mes.ProcessAfterUpdate"
	ProcessEventAfterSave    = "mes.ProcessAfterCreate mes.ProcessAfterUpdate"
	ProcessEventDelete       = "mes.ProcessDelete"

	ProcessAccessControlEvent = "mes.ProcessAccessControl"
)

func GetProcessConfig() *mgo.DocConfig {
	return Process_Config
}

var Process_Config *mgo.DocConfig

func init() {
	Process_Config = NewProcessConfig()
}

func NewProcessConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.Process",
		Fields: []string{
			"name", "department", "code",
		},
		RelationFields: []string{
			"department",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"department": {
				Config:     GetDepartmentConfig,
				DocName:    "Department",
				JoinType:   "O",
				KeyInside:  "departmentId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
